import requests

# 进入豆瓣电影首页
url1 = 'https://movie.douban.com/'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0',
}

resp = requests.get(url1, headers=headers)
print(resp.status_code)
# resp.encoding = 'utf-8-sig'
print(resp.text)
print(resp.encoding)

# 手机号归属地 案例
url2 = r'http://apis.juhe.cn/mobile/get'
data = {
    'phone': '17633730631',
    'key': '18b2e043e5ccb6d4f1b667b6681da9bb',
    'dtype': 'json'
}
# # get 方法
# resp = requests.get(url2,params=data,headers=headers)
# print(resp.status_code)
# resp.encoding = 'utf-8'
# print(resp.text)
#
# post方法
resp = requests.post(url2, data=data, headers=headers)
print(resp.status_code)
resp.encoding = 'utf-8'
print(resp.text)

# # # 百度搜索 案例
# url3 = r'http://www.baidu.com'
# # get 方法
# data = {'wd':'郑州天气'}
# resp = requests.get(url3,params=data,headers=headers)
# print(resp.status_code)
# resp.encoding= 'utf-8'
# patt = r'<title>(.*?)</title>'
# title = re.findall(patt, resp.text)
# print(title)
#
# # 星座运势 案例
# headers = {
# 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0",
# 'Content-Type':'application/x-www-form-urlencoded'
# }
#
# url4 = r'http://web.juhe.cn/constellation/getAll'
# data = {
#     'key':'49f81b8a2b0133639ba9b4a06f1e1d91',
#     'consName':'狮子座',
#     'type':'today'
# }
# resp = requests.get(url4,params=data,headers=headers)
# print(resp.status_code)
# resp.encoding = 'utf-8'
# print(resp.text)
